package redis

import (
	"github.com/garyburd/redigo/redis"
	"time"
)

var Pool *redis.Pool

// InitPool @Description: 初始化redis连接池
// @param address 地址
// @param maxIdle 最大空闲时间
// @param maxActive Maximum number of connections allocated by the pool at a given time.
// @param timeout
func InitPool(address string, maxIdle int, maxActive int, timeout time.Duration) {
	Pool = &redis.Pool{
		MaxIdle:     maxIdle,
		MaxActive:   maxActive,
		IdleTimeout: timeout,
		Dial: func() (redis.Conn, error) {
			conn, err := redis.Dial("tcp", address)
			if err != nil {
				return nil, err
			}
			return conn, nil
		},
	}
}
